﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using GalaSoft.MvvmLight.Messaging;
using MishraReader.PlatformVMs;
using MishraReader.Tools;
using MishraReader.ViewModels.AppServices;
using MishraReader.ViewModels.Settings;
using MishraReader.ViewModels.Tools;
using Ninject;
using Ninject.Modules;
using Ninject.Parameters;

namespace MishraReader
{
    internal class MishraReaderModule : NinjectModule
    {
        public override void Load()
        {
            Bind<IErrorService>()
                .To<ErrorService>()
                .InSingletonScope();

            Bind<IMessenger>()
                .ToConstant(Messenger.Default);

            Bind<IWpfApplication>()
                .To<WpfApplication>()
                .InSingletonScope();

            Bind<IOptionsManager>()
                .To<OptionsManager>()
                .InSingletonScope();

            Bind<IUrlLauncher>()
                .To<UrlLauncher>()
                .InSingletonScope();

            Bind<ICredentialProvider>()
                .To<CredentialProvider>();

            Bind<ISettingsManager>()
                .To<SettingsManager>()
                .InSingletonScope();

            Bind<ISettingsViewModel>().To<SettingsViewModel>();

            Bind<IWrappedCollectionViewSource>().To<WrappedCollectionViewSource>();

            Bind<Func<Window, IWindowPositionTracker>>()
                .ToMethod(
                    ctx =>
                    window =>
                    ctx.Kernel.Get<WindowPositionTracker>(new ConstructorArgument("window", window)));
        }
    }
}